home *** CD-ROM | disk | FTP | other *** search
/ Aminet 30 / Aminet 30 (1999)(Schatztruhe)[!][Apr 1999].iso / Aminet / gfx / ifx / card_prep.lha / Card_prep.ifx next >
Text File  |  1999-02-21  |  8KB  |  335 lines

  1. /* 
  2.  * $VER: Card_prep.ifx 2.0 (16.2.99)
  3.  *
  4.  * Tested with IFX 1.52, 2.6 and 3.3
  5.  *
  6.  * This script will crop and/or add a border to the buffer so it
  7.  * will have the proper proportions when it eventually gets scaled
  8.  * down to a card image for Soliton or REKO card sets.  This script
  9.  * will also do the scaling for you, if you like.
  10.  *
  11.  * IMPORTANT!
  12.  *     Make sure the image you plan to use this
  13.  *     script with is set to the correct aspect.
  14.  *
  15.  * If you want the image cropped, use the box region tool before you
  16.  * run this script to define the area of the image you wish to keep.
  17.  * The script will then find the smallest card-shaped area which can
  18.  * contain the area you have defined.
  19.  *
  20.  * The Reko cardset setting assumes you will be viewing the finished cards
  21.  * on a PAL display. If this is not the case then select "Custom" cardset
  22.  * type, set the width and height to 88 and 130 respectively, and choose
  23.  * the correct display type.
  24.  *
  25.  * I GUARANTEE NOTHING. YOU USE THIS SCRIPT AT YOUR OWN RISK!
  26.  *
  27.  * Do with it and edit it as you like.
  28.  *
  29.  *
  30.  *           ****  Written by Cary Driscoll  ****
  31.  *
  32.  *              ****  cdriscol@flash.net  ****
  33.  */
  34.  
  35. OPTIONS RESULTS
  36.  
  37. getversion
  38. PARSE VAR RESULT name ifx_version date
  39.  
  40. getmain
  41.  
  42. IF ifx_version < 2 THEN DO
  43.     IF result = "" THEN DO
  44.         RequestNotify "No image Loaded!"
  45.         EXIT
  46.     END
  47. END
  48. ELSE DO
  49.     IF rc ~= 0 THEN DO
  50.         RequestNotify "No image Loaded!"
  51.         EXIT
  52.     END
  53. END
  54.  
  55. Parse var result name picwidth picheight depth Xaspect Yaspect .
  56.  
  57. getregionarea
  58.  
  59. IF rc ~= 0 THEN DO
  60.   left = 0
  61.   top = 0
  62.   width = picwidth
  63.   height = picheight
  64. END
  65. ELSE DO
  66.   PARSE VAR RESULT left top width height
  67. END
  68.  
  69. Region Full
  70.  
  71. /* Retrieve previous values from the environment */
  72. CardSet      = GETCLIP('Card_CardSet')
  73. Display      = GETCLIP('Card_Display')
  74. Hires        = GETCLIP('Card_Hires')
  75. Lace         = GETCLIP('Card_Lace')
  76. Card_Width   = GETCLIP('Card_X')
  77. Card_Height  = GETCLIP('Card_Y')
  78. Sharp        = GETCLIP('Card_Sharp')
  79. Sharp_N      = GETCLIP('Card_Sharp_N')
  80. Con          = GETCLIP('Card_Con')
  81. Con_N        = GETCLIP('Card_Con_N')
  82.  
  83. /* If empty values are returned from the environment, set these to the following: */
  84. IF CardSet     = '' THEN CardSet     = 0   /* Defaults to REKO           */
  85. IF Display     = '' THEN Display     = 0   /* "Custom" defaults to NTSC  */
  86. IF Hires       = '' THEN Hires       = 0
  87. IF Lace        = '' THEN Lace        = 0
  88. IF Card_Width  = '' THEN Card_Width  = 88  /* Default custom card width  */
  89. IF Card_Height = '' THEN Card_Height = 130 /* Default custom card height */
  90. IF Sharp       = '' THEN Sharp       = 1
  91. IF Sharp_N     = '' THEN Sharp_N     = 40  /* Default sharpening         */
  92. IF Con         = '' THEN Con         = 1
  93. IF Con_N       = '' THEN Con_N       = 10  /* Default contrast           */
  94.  
  95. IF ifx_version < 2 THEN DO
  96.     Gadget.1 = 'C/60/19//2/REKO/Custom'
  97.     ComplexRequest '"Cardset Type"' 1 Gadget 220 55
  98.     IF rc ~= 0 THEN EXIT
  99. END
  100. ELSE DO
  101.     Gadget.1 = 'CYCLE LE=75 TE=5 LB=Game: IN='||CardSet||' CH=REKO/Custom'
  102.     Gadget.2 = END
  103.     NewComplexRequest '"Cardset Type"' Gadget 205 24
  104.     IF rc ~= 0 THEN EXIT
  105. END
  106.  
  107. CardSet = result.1
  108.  
  109. IF CardSet = 0 THEN DO
  110.     Display      = 1
  111.     Hires        = 0
  112.     Lace         = 0
  113.     Card_Width   = 88
  114.     Card_Height  = 130
  115.     Card_Xaspect = 12
  116.     Card_Yaspect = 11
  117. END
  118. ELSE DO
  119.     IF ifx_version < 2 THEN DO
  120.         Gadget.1 = 'C/85/15/Display:/3/NTSC/PAL/VGA'
  121.         Gadget.2 = 'X/170/32/Hires?/'Hires
  122.         Gadget.3 = 'X/170/49/Lace?/'Lace
  123.         Gadget.4 = 'J/110/30/40/Card Width/'||Card_Width
  124.         Gadget.5 = 'J/110/47/40/Card Height/'||Card_Height
  125.         ComplexRequest '"Custom Card Setting"' 5 Gadget 273 82
  126.         IF rc ~= 0 THEN EXIT
  127.     END
  128.     ELSE DO
  129.         Gadget.1 = 'CYCLE LE=110 TE=5 LB=Display: IN='||Display||' CH=NTSC/PAL/VGA'
  130.         Gadget.2 = 'CHECK LE=170 TE=22 LB=Hires? IN='||Hires
  131.         Gadget.3 = 'CHECK LE=170 TE=39 LB=Lace? IN='||Lace
  132.         Gadget.4 = 'INTEGER LE=110 TE=20 WD=40 LB="Card Width" IN='||Card_Width
  133.         Gadget.5 = 'INTEGER LE=110 TE=37 WD=40 LB="Card Height" IN='||Card_Height
  134.         Gadget.6 = END
  135.         NewComplexRequest '"Custom Card Settings"' Gadget 273 57
  136.         IF rc ~= 0 THEN EXIT
  137.     END
  138.  
  139.     Display     = result.1
  140.     Hires       = result.2
  141.     Lace        = result.3
  142.     Card_Width  = result.4
  143.     Card_Height = result.5
  144.  
  145.     IF Display = 0 THEN DO  /* NTSC */
  146.         IF Hires = Lace THEN DO
  147.             Card_Xaspect = 11
  148.             Card_Yaspect = 13
  149.         END
  150.         ELSE DO
  151.             IF Hires = 1 THEN DO
  152.                 Card_Xaspect = 11 
  153.                 Card_Yaspect = 26
  154.             END
  155.             ELSE DO
  156.                 Card_Xaspect = 22
  157.                 Card_Yaspect = 13
  158.             END
  159.         END
  160.     END
  161.     IF Display = 1 THEN DO  /* PAL */
  162.         IF Hires = Lace THEN DO
  163.             Card_Xaspect = 12
  164.             Card_Yaspect = 11
  165.         END
  166.         ELSE DO
  167.             IF Hires = 1 THEN DO
  168.                 Card_Xaspect = 6 
  169.                 Card_Yaspect = 11
  170.             END
  171.             ELSE DO
  172.                 Card_Xaspect = 24
  173.                 Card_Yaspect = 11
  174.             END
  175.         END
  176.     END
  177.     IF Display = 2 THEN DO  /* VGA */
  178.         IF Hires = Lace THEN DO
  179.             Card_Xaspect = 1
  180.             Card_Yaspect = 1
  181.         END
  182.         ELSE DO
  183.             IF Hires = 1 THEN DO
  184.                 Card_Xaspect = 1 
  185.                 Card_Yaspect = 2
  186.             END
  187.             ELSE DO
  188.                 Card_Xaspect = 2
  189.                 Card_Yaspect = 1
  190.             END
  191.         END
  192.     END
  193. END
  194.  
  195. /* Store the given values in the environment for the next run */
  196. CALL SETCLIP('Card_CardSet',CardSet)
  197. CALL SETCLIP('Card_Display',Display)
  198. CALL SETCLIP('Card_Hires',Hires)
  199. CALL SETCLIP('Card_Lace',Lace)
  200. CALL SETCLIP('Card_X',Card_Width)
  201. CALL SETCLIP('Card_Y',Card_Height)
  202.  
  203. Ratio = ((Card_Height * Card_Yaspect) / (Card_Width * Card_Xaspect)) * (Xaspect / Yaspect)
  204.  
  205. H = height
  206. W = width
  207. TestH = W * Ratio
  208.  
  209. IF height < TestH THEN H = TestH
  210. ELSE W = H % Ratio
  211.  
  212. C = 0
  213. IF H > picheight THEN C = 1
  214. IF W > picwidth THEN C = 2
  215.  
  216. Redraw Off
  217.  
  218. IF C = 0 THEN DO
  219.   IF H = height THEN DO
  220.     L = left - (W - width) % 2
  221.     IF L < 0 THEN L = 0
  222.     IF L + W > picwidth THEN L = picwidth - W
  223.     Crop L top W H
  224.   END
  225.   ELSE DO
  226.     T = top - (H - height) % 2
  227.     IF T < 0 THEN T = 0
  228.     IF T + H > picheight THEN T = picheight - H
  229.     Crop left T W H
  230.   END
  231. END
  232.  
  233. IF C = 1 THEN DO
  234.   Scale picwidth H BORDER
  235.   Crop left 0  W H
  236. END
  237.  
  238. IF C = 2 THEN DO
  239.   Scale W picheight BORDER
  240.   Crop 0 top W H
  241. END
  242.  
  243. Redraw On
  244.  
  245. IF C ~= 0 THEN DO
  246.     RequestResponse "Do you want ""zoom"" borders?"
  247.     IF rc = 0 THEN DO
  248.         RequestResponse "Are you sure? This could take a while."
  249.         IF rc = 0 THEN DO
  250.             Redraw Off
  251.             Undo Off
  252.             IF C = 1 THEN DO
  253.                 B = (H - picheight) % 2
  254.                 Scissors
  255.                 Box 0 B W 1
  256.                 DO x = 0 to B
  257.                     Scale W+2*x 1
  258.                     Point W%2-x B-x
  259.                 END
  260.                 B = B + picheight - 1
  261.                 Scissors
  262.                 Box 0 B W 1
  263.                 DO x = 0 to H-B
  264.                     Scale W+2*x 1
  265.                     Point W%2-x B+x
  266.                 END
  267.                 KillBrush
  268.             END
  269.             ELSE DO
  270.                 B = (W - picwidth) % 2
  271.                 Scissors
  272.                 Box B 0 1 H
  273.                 DO x = 0 to B
  274.                     Scale 1 H+2*x
  275.                     Point B-x H%2-x
  276.                 END
  277.                 B = B + picwidth - 1
  278.                 Scissors
  279.                 Box B 0 1 H
  280.                 DO x = 0 to W-B
  281.                     Scale 1 H+2*x
  282.                     Point B+x H%2-x
  283.                 END
  284.                 KillBrush
  285.             END
  286.             Undo On
  287.             Redraw On
  288.         END
  289.     END
  290. END
  291.  
  292. RequestResponse "Do you want this image scaled?"
  293. IF rc ~= 0 THEN EXIT
  294.  
  295. SetAspect Card_Xaspect Card_Yaspect
  296. Scale Card_Width Card_Height
  297.  
  298. IF ifx_version < 2 THEN DO
  299.     Gadget.1 = 'X/15/15/Sharpen?/'Sharp
  300.     Gadget.2 = 'X/15/32/Contrast?/'Con
  301.     Gadget.3 = 'J/220/14/45/0 to 255   /'Sharp_N
  302.     Gadget.4 = 'J/220/31/45/-127 to +127 /'Con_N
  303.     ComplexRequest '"Sharpen and Contrast"' 4 Gadget 290 65
  304.     IF rc ~= 0 THEN EXIT
  305. END
  306. ELSE DO
  307.     Gadget.1 = 'CHECK LE=15 TE=5 LB=Sharpen? IN='||Sharp
  308.     Gadget.2 = 'CHECK LE=15 TE=22 LB=Contrast? IN='||Con
  309.     Gadget.3 = 'INTEGER LE=225 TE=4 WD=45 LB="0 to 255   " IN='||Sharp_N
  310.     Gadget.4 = 'INTEGER LE=225 TE=21 WD=45 LB="-127 to +127 " IN='||Con_N
  311.     Gadget.5 = END
  312.     NewComplexRequest '"Sharpen and Contrast"' Gadget 290 40
  313.     IF rc ~= 0 THEN EXIT
  314. END
  315.  
  316. Sharp   = result.1
  317. Con     = result.2
  318. Sharp_N = result.3
  319. Con_N   = result.4
  320.  
  321. IF Sharp_N < 0 THEN Sharp_N = 0
  322. IF Sharp_N > 255 THEN Sharp_N = 255
  323. IF Con_N < -127 THEN Con_N = -127
  324. IF Con_N > 127 THEN Con_N = 127
  325.  
  326. IF Con = 1 THEN Contrast Con_N
  327. IF Sharp = 1 THEN Sharpen Sharp_N
  328.  
  329. CALL SETCLIP('Card_Sharp',Sharp)
  330. CALL SETCLIP('Card_Sharp_N',Sharp_N)
  331. CALL SETCLIP('Card_Con',Con)
  332. CALL SETCLIP('Card_Con_N',Con_N)
  333.  
  334. EXIT
  335.